//
//  FileDetailViewController.m
//  Exam
//
//  Created by mac on 2019/8/26.
//  Copyright © 2019年 Changzhou Jinzhineng Software Co., Ltd. All rights reserved.
//

#import "FileDetailViewController.h"
#import "ColorUtil.h"
#import "JznWebView.h"
#import <Masonry.h>
#import "MBProgressHUD.h"
@interface FileDetailViewController ()
@property(nonatomic, strong) JznWebView *jznWebView;
@property(nonatomic, strong) MBProgressHUD *hub;
@end

@implementation FileDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"文件详情";
    UINavigationBar * bar = self.navigationController.navigationBar;
    UIImage *bgImage = [ColorUtil navigationBarColor:[ColorUtil titleColor] BarSize:bar.frame alphe:1.0];
    [bar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
    [bar setTintColor:[UIColor whiteColor]];
    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]}forState:UIControlStateNormal];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]];
    
    [self.view addSubview:self.jznWebView];
    [self.jznWebView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.view);
    }];
    NSURL *pdfURL = [NSURL fileURLWithPath:self.documentName];
    NSURLRequest *request = [NSURLRequest requestWithURL:pdfURL];
    [self.jznWebView loadRequest:request];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation{

    self.hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    self.hub.labelText = @"文件正在解码，请稍后";
}

- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{

    [self.hub setHidden:YES];
}
@end
